from flask import g, current_app

class Logger:

    @staticmethod
    def info(content):
        log_context = g.get('log_context', default={})
        current_app.logger.info(content, extra=log_context)

    @staticmethod
    def debug(content):
        log_context = g.get('log_context', default={})
        current_app.logger.debug(content, extra=log_context)

    @staticmethod
    def warning(content):
        log_context = g.get('log_context', default={})
        current_app.logger.warning(content, extra=log_context)

    @staticmethod
    def error(ex, content):
        log_context = g.get('log_context', default={})
        current_app.logger.error(content, extra=log_context, exc_info=ex)

logger = Logger()